import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import local_get from '@dfeidao/atom-web/local/get';
import local_remove from '@dfeidao/atom-web/local/remove';
import local_set from '@dfeidao/atom-web/local/set';
import render from '@dfeidao/atom-web/render/render';
import P01 from './P01';
// 接收选择控制点返回的选中数据并渲染至控制点列表中
export default async function a006(fd: IFeidaoAiBrowserComponent, args: { data: [] }) {
	const data = local_get(fd, "data") as [];
	Array.from(args.data).forEach((a) => {
		data.push(a);
	});
	local_set(fd, "data", data);
	render(fd, { dataArray: data }, P01, 'P01', 'inner');
	const del_data: string[] = local_get(fd, "del_data");
	let arr2 = new Array();
	if (del_data) {
		arr2 = del_data.concat();
	}
	if (del_data) {
		Array.from(args.data).forEach((a: { code: string }) => {
			Array.from(del_data).forEach((b: string) => {
				if (a.code.toString() === b) {
					arr2 = arr2.splice(del_data.indexOf(b), 1);
				}
			});
		});
	}
	if (arr2.length > 0) {
		local_set(fd, "del_data", arr2);
	} else {
		local_remove(fd, "del_data");
	}
}
